# encoding=utf8
import sys
reload(sys)
sys.setdefaultencoding('utf8')

class JT_9102:
    result = []
    analysisDescription=['逻辑通道号:','控制指令:','关音视频:','切换码流:']
    analysis9102Length=[1,1,1,1]
    def LogicAisle(self, protocolStr, header):
        count = 0
        s=""
        for i in range(len(self.analysisDescription)):
            # 控制指令
            if i==1:
                s=protocolStr[count:count + (self.analysis9102Length[i] * 2)]
                if s=="00":
                    header.append(self.analysisDescription[i] + s + " 关音视频" + "\n")
                elif s=="01":
                    header.append(self.analysisDescription[i] + s + " 切换码流" + "\n")
                elif s=="02":
                    header.append(self.analysisDescription[i]+ s +" 暂停"+"\n")
                elif s=="03":
                    header.append(self.analysisDescription[i]+ s +" 恢复"+"\n")
                elif s=="04":
                    header.append(self.analysisDescription[i] + s + " 关双向对讲" + "\n")
                count = count + self.analysis9102Length[i] * 2
            #关音视频类型
            elif i==2:
                s = protocolStr[count:count + (self.analysis9102Length[i] * 2)]
                if s=="00":
                    header.append(self.analysisDescription[i] + s + " 关音视频" + "\n")
                elif s=="01":
                    header.append(self.analysisDescription[i] + s + " 只关音频" + "\n")
                elif s=="02":
                    header.append(self.analysisDescription[i] + s + " 只关视频" + "\n")
                count = count + self.analysis9102Length[i] * 2
            #切换码流类型
            elif i==3:
                s = protocolStr[count:count + (self.analysis9102Length[i] * 2)]
                if s == "00":
                    header.append(self.analysisDescription[i] + s + " 主码流" + "\n")
                elif s == "01":
                    header.append(self.analysisDescription[i] + s + " 子码流" + "\n")
                count = count + self.analysis9102Length[i] * 2
            elif i==1 or i==0:
                header.append(self.analysisDescription[i] + protocolStr[count:count + (self.analysis9102Length[i] * 2)]+"\n")
                count = count + self.analysis9102Length[i] * 2

        self.result=header
